<template>
	<div class="step1">
		<ul class="uls" v-if="!isBaseDisabled && !['3', '7'].includes(btnType)">
			<li class="lis">
				<div class="div2">
					<el-form><el-form-item label="责任人" required></el-form-item></el-form>
				</div>
				<div class="div2">
					<el-select v-model="fundBaseInfo.personLiableId" :disabled="isBaseDisabled" filterable clearable @change="focusUpdate">
						<el-option
							v-for="(item, index) in commonPersonList"
							:key="index + 'a'"
							:label="item.firstName"
							:value="item.username"
							:disabled="item.username == fundBaseInfo.checkLiableId"
						/>
					</el-select>
					<div class="blurmsg" v-if="isCheck && !!!fundBaseInfo.personLiableId">请选择责任人</div>
				</div>
				<div class="div2">
					<el-form><el-form-item label="复核人" required></el-form-item></el-form>
				</div>
				<div class="div2">
					<el-select v-model="fundBaseInfo.checkLiableId" :disabled="isBaseDisabled" filterable clearable @change="focusUpdate">
						<el-option
							v-for="(item, index) in commonPersonList"
							:key="index + 'b'"
							:label="item.firstName"
							:value="item.username"
							:disabled="item.username == fundBaseInfo.personLiableId"
						/>
					</el-select>
					<div class="blurmsg" v-if="isCheck && !!!fundBaseInfo.checkLiableId">请选择复核人</div>
				</div>
			</li>
		</ul>

		<ul class="uls" v-show="['3', '7'].includes(btnType)">
			<li class="lis">
				<div class="div1">
					<el-form><el-form-item label="日期" required></el-form-item></el-form>
				</div>
				<div class="div3">
					<el-date-picker
						type="date"
						v-model="fundBaseInfo.changeDate"
						value-format="yyyyMMdd"
						format="yyyyMMdd"
						:disabled="isBaseDisabled"
						@change="focusUpdate"
					></el-date-picker>
					<div class="blurmsg" v-if="isCheck && !!!fundBaseInfo.changeDate">请选择日期</div>
				</div>
			</li>
			<li class="lis" v-show="isEnterDateHtmlPro == '3'">
				<div class="div1">
					<el-form><el-form-item label="募集状态" required></el-form-item></el-form>
				</div>
				<div class="div3">
					<el-select v-model="fundBaseInfo.raisingStatus" filterable clearable :disabled="isBaseDisabled" @change="focusUpdate">
						<el-option value="0" label="募集成功"> </el-option>
						<el-option value="1" label="募集失败"> </el-option>
					</el-select>
					<div class="blurmsg" v-if="isCheck && !!!fundBaseInfo.raisingStatus">请选择募集状态</div>
				</div>
			</li>
			<li class="lis">
				<div class="div1">
					<el-form><el-form-item label="备注" required></el-form-item></el-form>
				</div>
				<div class="div3">
					<el-input
						type="textarea"
						@input="focusUpdate"
						v-model.trim="fundBaseInfo.changeRemark"
						:disabled="isBaseDisabled"
						show-word-limit
						style="width: 100%"
					/>
					<div class="blurmsg" v-if="isCheck && !!!fundBaseInfo.changeRemark">请输入备注</div>
				</div>
			</li>
		</ul>
	</div>
</template>
<script>
import { departmentUser } from '@/api/productApi/fundManager'
import { newSubmit } from '@/api/productApi/infoMain'
import { jsonArray } from '@/api/productApi/file'
import { submitPageReview } from '@/views/infoMain/publicList/components/dataReview'
export default {
	props: {
		setpFunc: {
			type: Function,
			default: Function
		},
		submitSuccess: {
			type: Function,
			default: Function
		},
		loadingShow: {
			type: Function,
			default: Function
		},
		fundSysCode: {
			type: String,
			default: ''
		},
		dataType: {
			type: String,
			default: ''
		},
		isEnterDateHtmlPro: {
			type: String,
			default: ''
		}
	},
	data() {
		return {
			fundBaseInfo: {
				changeDate: new Date()
			},
			commonPersonList: [],
			cuserId: '',
			isBaseDisabled: false,
			isCheck: false
		}
	},

	computed: {
		btnType() {
			return this.dataType
		}
	},

	async mounted() {
		await this.getUserOpList()
	},

	methods: {
		focusUpdate(property) {
			this.$forceUpdate()
		},

		// 重新申请将数据集中在store
		updateStoreData() {
			this.$store.state.fundStep.pucliktTotalData.fundCustodianInfo = this.fundBaseInfo
		},

		isBaseDisabledCom(data, msgShow) {
			this.isBaseDisabled = data
			this.isCheck = msgShow
		},

		ValidationRequired() {
			return submitPageReview(this.fundBaseInfo, this.isEnterDateHtmlPro, this.btnType)
		},

		save() {
			this.isCheck = true
            const msg = `${!submitPageReview(this.fundBaseInfo, this.isEnterDateHtmlPro, this.btnType).length ? '此操作将永久提交已编辑数据，是否继续' : `必填项 “ ${submitPageReview(this.fundBaseInfo, this.isEnterDateHtmlPro, this.btnType).join('、')} ” 未填写，是否确认提交`}？`
			this.CustomtextComfirm(() => {
				this.$emit('loadingShow', true)
				this.fundBaseInfo.fundSysCode = this.fundSysCode
				this.fundBaseInfo.fundRaiseType = '1'
				newSubmit(this.fundBaseInfo).then(res => {
					if (res.msgCode === 'Y') {
						this.$message({ type: 'success', message: res.msg })
						this.$emit('submitSuccess')
					}
					this.$emit('loadingShow', false)
				})
			}, `${msg}`)
		},

		edit(data) {
			if (!this.isBaseDisabled && !['3', '7'].includes(this.btnType)) {
				if (this.commonPersonList.some(item => item.username === this.$store.state.user.name)) {
					this.$set(data, 'personLiableId', this.$store.state.user.name)
				}
				data.checkLiableId = ''
			}
			this.fundBaseInfo = jsonArray(data)
			this.$forceUpdate(this.fundBaseInfo)
		},

		// 查询：获取拥有某权限的用户信息
		async getUserOpList() {
			await departmentUser({ roleCodeList: ['PRODUCT_MANAGER'] }).then(res => {
				if (res.msgCode === 'Y') {
					this.commonPersonList = res.data.body
					if (!this.isBaseDisabled && !['3', '7'].includes(this.btnType)) {
						if (this.commonPersonList.some(item => item.username === this.$store.state.user.name)) {
							this.$set(this.fundBaseInfo, 'personLiableId', this.$store.state.user.name)
						}
						this.fundBaseInfo.checkLiableId = ''
					}
				}
			})
		}
	}
}
</script>
<style lang="scss" scoped >
</style>
